<script>
  
import Vue from 'vue'

import User from '@/class/user/user.js'
import msg from '@/utils/common/massage.js'
  
export default {
	onLaunch: function() {
    // 初始化UI参数
    this.initUIParams()
    // 自动登录
    this.autoLogin()
	},
	onShow: function() {
	},
	onHide: function() {
	},
  methods: {
    // 自动登录
    autoLogin () {
      const user = new User()
      user.autoLogin().then(() => {
        console.log('自动登录成功', user)
        this.$u.msg.toast('登录成功')
      })
      .catch((e) => {
        console.log(e)
        // 自动登录失败不用提示
      })
    },
    
    // 初始化UI参数
    initUIParams () {
      uni.getSystemInfo({
        success: function(e) {
          // 获取页面高度
          Vue.prototype.windowWidth = e.windowWidth
          Vue.prototype.windowHeight = e.windowHeight
          
          // #ifndef MP
          Vue.prototype.StatusBar = e.statusBarHeight
          if (e.platform == 'android') {
            Vue.prototype.CustomBar = e.statusBarHeight + 50
          } else {
            Vue.prototype.CustomBar = e.statusBarHeight + 45
          }
          // #endif

          // #ifdef MP-WEIXIN
          Vue.prototype.StatusBar = e.statusBarHeight
          let custom = wx.getMenuButtonBoundingClientRect()
          Vue.prototype.Custom = custom
          Vue.prototype.CustomBar = custom.bottom + (custom.top - e.statusBarHeight) * 2
          // #endif		

          // #ifdef MP-ALIPAY
          Vue.prototype.StatusBar = e.statusBarHeight
          Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight
          // #endif
        }
      })
    }
  }
};

</script>

<style lang="stylus">
/* 导入公共样式 */
@import './styles/cu-icon.css'
@import './styles/iconfont.css'
@import './styles/style.styl'

/* 全局设置背景色等通用样式 */
page
  background-color $app-bg-color
  font-family Helvetica Neue, Helvetica, sans-serif
  line-height 1
  font-size 16px

view
scroll-view
swiper
button
input
textarea
label
navigator
image
	box-sizing border-box

::-webkit-scrollbar
  display: none
  width: 0 !important
  height: 0 !important 
  -webkit-appearance: none
  background: transparent 

/* 解决头条小程序组件内引入字体不生效的问题 */
/* #ifdef MP-TOUTIAO */
@font-face {
	font-family: uniicons;
	src: url('/static/uni.ttf');
}
/* #endif */
</style>
